<template>
  <div>
    <van-nav-bar
        title="我的收藏"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
    />
    <van-skeleton title :row="3" v-for="item in 5" :key="item" v-show="isShow" style="margin-bottom: 30px"/>
    <van-empty description="暂无收藏" v-if="subscribeList.length == 0" v-show="!isShow"/>
    <ul v-else>
      <li v-for="item in subscribeList" :key="item.articleId" @click="toDetail(item.articleId)">
        <div>
          <div>{{ item.title }}</div>
          <span>{{item.articleSource}}</span>
          <span>{{item.createTime}}</span>
        </div>
        <img :src="item.bannerImgUrl" alt="">
      </li>
    </ul>
  </div>
</template>

<script>
import {getSubscribe} from "@/http/api";

export default {
  name: "Collect",
  data() {
    return {
      subscribeList:[],
      isShow:true
    }
  },
  components:{
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1)
    },
    //跳转到详情页
    toDetail(articleId){
      this.$router.push({path:'/detail',query:{articleId:articleId}})
    },

  },
  created() {
    //请求回来的收藏列表
    getSubscribe().then(res => {
      this.isShow = false
      this.subscribeList = res.data.rows
    })
  }
}
</script>

<style scoped lang="less">
ul {
  padding-bottom: 50px;
  >li {
    padding: 5px 15px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    > div {
      width: calc(100% - 135px);
      > div {
        font-size: 20px;
        margin-bottom: 8px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        height: 58px;
        line-height: 30px;
      }

      > span:nth-of-type(1) {
        font-size: 14px;
        padding-right: 15px;
        display: inline-block;
        width: calc(100% - 75px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: 700;
        color: #f5270c;
      }

      > span:nth-of-type(2) {
        font-size: 14px;
        display: inline-block;
        overflow: hidden;
        white-space: nowrap;
        width: 75px;
        float: right;
        color: #938d8d;
      }
    }
    >img{
      height: 80px;
      width: 125px;
    }
  }
}
</style>